---
title: "Design Class Diagram — RVC Controller SW v2"
---
classDiagram
    direction TB

    class RVCState {
        <<enumeration>>
        CLEANING
        STOPPED
        TURNING
        REVERSING
    }
    class Direction {
        <<enumeration>>
        FORWARD
        BACKWARD
        LEFT
        RIGHT
    }
    class PowerLevel {
        <<enumeration>>
        NORMAL
        BOOSTED
    }
    class SensorStatus {
        <<enumeration>>
        ACTIVE
        ERROR
    }
    class SensorPosition {
        <<enumeration>>
        FRONT
        LEFT
    }

    class RVC {
        -state : RVCState
        +startCleaning() void
    }

    class Controller {
        -pollingInterval : int
        +startCleaning() void
        +reportObstacle(position : SensorPosition) void
        +reportDust(dustLevel : float) void
        +reportSensorError(sensorId : String) void
        -avoidFrontObstacle() void
        -avoidAllDirectionObstacle() void
        -boostCleaningPower() void
        -pollSensors() void
        -checkSideObstacles() void
        -recordObstacleDetection(position : SensorPosition) void
        -recordDustDetection(dustLevel : float) void
        -validateSensorData(sensorId : String) boolean
        -retainLastValidState() void
    }

    class MovementUnit {
        -currentDirection : Direction
        -speed : float
        +moveForward() void
        +moveBackward() void
        +stop() void
        +turn(direction : Direction) void
        +getDirection() Direction
    }

    class CleaningUnit {
        -powerLevel : PowerLevel
        -boostDuration : int
        -isActive : boolean
        +startCleaning() void
        +setPowerLevel(level : PowerLevel) void
        +boostPower() void
        +restoreNormalPower() void
        +getIsActive() boolean
    }

    class Sensor {
        <<abstract>>
        -sensorId : String
        -status : SensorStatus
        +getStatus() SensorStatus
        +getSensorId() String
        +readData()* Object
    }

    class ObstacleSensor {
        -position : SensorPosition
        -obstacleDetected : boolean
        +isObstacleDetected() boolean
        +getPosition() SensorPosition
        +readData() boolean
    }

    class DustSensor {
        -dustLevel : float
        -dustDetected : boolean
        +isDustDetected() boolean
        +getDustLevel() float
        +readData() float
    }

    RVC "1" *-- "1" Controller
    RVC "1" *-- "1" MovementUnit
    RVC "1" *-- "1" CleaningUnit
    Controller "1" o-- "1..*" Sensor
    Controller "1" --> "1" MovementUnit
    Controller "1" --> "1" CleaningUnit
    Sensor <|-- ObstacleSensor
    Sensor <|-- DustSensor

    RVC ..> RVCState
    MovementUnit ..> Direction
    CleaningUnit ..> PowerLevel
    Sensor ..> SensorStatus
    ObstacleSensor ..> SensorPosition

    style SensorPosition fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style Controller     fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style ObstacleSensor fill:#fff3e0,stroke:#e65100,stroke-width:2px
